function check() {
    var username = document.getElementById("username");
    var value1 = username.value;
    //用户名（4到16位，字母数字下划线，减号）
    var patt1 = /^[-_a-zA-Z0-9]{4,16}$/;
    var sp1 = document.getElementById("sp1");
    if (value1 == "") {
        tip.innerHTML = "账号输入不能为空";
        return false;
    }
    if (!patt1.test(value1)) {
        tip.innerHTML = "账号输入不合法!";
        return false;
    } else {
        tip.innerHTML = "";
    }
    //密码由英文字母和数字组成的4-10位字符
    var patt2 = /^[a-zA-Z0-9]{4,10}$/;
    var password = document.getElementById("password");
    var value2 = password.value;
    var sp2 = document.getElementById("sp2");
    if (value2 == "") {
        tip.innerHTML = "密码输入不能为空";
        return false;
    }
    if (!patt2.test(value2)) {
        tip.innerHTML = "密码输入不合法!";
        return false;
    } else {
        tip.innerHTML = "";
    }
}
